Validating programs

ABSTRACT

Methods and apparatus, including computer program products implement techniques for validating programs. A language-independent description of a computer program is received, and the language-independent description is validated. The language-independent description includes a definition module and an implementation module. A language-dependent program is generated from the language-independent description, where the language-dependent program includes an interface and a class, and the language-dependent program is validated.

CROSS-REFERENCE TO RELATED APPLICATIONS

[0001] This application claims the benefit of priority to European application serial no. 02022042.2, filed Oct. 1, 2002.

BACKGROUND

[0002] The present invention relates to data processing by digital computer, and more particularly to the validation of computer program applications.

[0003] A computer program application can include a computer program implemented in a compiler language, e.g., an object oriented programming language. Definition modules and implementation modules can be used to describe a computer program implemented in a compiler language. The implementation modules and definition modules can be stored in files of distinct types. In some object oriented programming languages, the definition modules are called interfaces and the implementation modules are called classes.

[0004] The two-component, definition-implementation model aids program verification by allowing early detection of some programming errors. The definition modules or interfaces can be viewed as a record of promises given by a class (the provider class). This record can be used to detect certain programming errors, e.g., where a second class (the customer class) relies on or attempts to use features of the provider class that have not been promised by the provider class. Interface modules can also be used to verify that the implementation of a provider class provides all the promised features.

[0005] Some computer program applications include script code sections. Script code sections can be implemented using an interpreted or scripting language, e.g., JavaScript or Perl. For purposes of this specification, a scripting language is a language that does not support interfaces and that is either weakly typed or untyped. Scripting languages can interact with other programs or with a set of functions provided by an interpreter for the scripting language, as with the file system functions provided in a UNIX shell. Because scripting languages do not support the definition-implementation model, it is difficult to detect errors in script code sections before runtime.

SUMMARY OF THE INVENTION

[0006] In general, in one aspect, the invention provides methods and apparatus, including computer program products, for the validation of computer program applications. The techniques include receiving the language-independent description of a computer program, while editing the language-independent description, generating a language-dependent program from the language-independent description, and validating the language-dependent program. The language-independent description includes a definition module and an implementation module. The language-dependent program includes an interface and a class.

[0007] Advantageous implementations of the invention include one or more of the following features. Validating the language-independent description can include validating the syntax of the definition module and the implementation module. Validating the language-dependent program can include compiling the interface and the class. The definition module and the implementation module can be represented in a meta-language or using a tree structure.

[0008] In another aspect, the invention provides methods and apparatus implementing techniques for the validation of programs including receiving a language-independent description of a computer program, validating the language-independent description, generating a language-dependent program from the language-independent description, and validating the language-dependent program. The language-independent description can include a definition module and an implementation module. The language-dependent program can include a script code section.

[0009] Advantageous implementations of the invention include one or more of the following features. Validating the language-dependent program can include extracting language elements from the script code section, and comparing the extracted language elements with the definition module. Extracting language elements can include generating a symbol table from the script code section. Generating the language-dependent program can include generating language-dependent code comprising an interface and a class. Validating the language-dependent program can include extracting language elements from the script code section, comparing the extracted language elements with the definition module, generating language-dependent code comprising an interface and a class, and compiling the interface and the class.

[0010] In another aspect, the invention provides methods and apparatus implementing techniques for validating programs. The techniques include receiving a language-independent description of a computer program, where the language-independent description includes a definition module and an implementation module, and validating the language-independent description. A first language-dependent program is generated from the language-independent description where the first language-dependent program includes a first script code section. A second language-dependent program is generated from the language-dependent description, where the second language-dependent program includes a second script code section of a distinct second kind. A first set of language elements is extracted from the first script code section, a second set of language elements is extracted from the second script code section, and the first set of language elements and the second set of language elements are compared with the definition module.

[0011] The invention can be implemented to realize one or more of the following advantages. Computer applications can be validated independently of the specific language used to implement the applications. Computer applications can also be validated at an early stage in the validation cycle. Computer applications implemented using programming languages that do not support the concept of validation or the concept of classes and interfaces, can be validated.

[0012] The details of one or more implementations of the invention are set forth in the accompanying drawings and the description below. Other features, aspects, and advantages of the invention will become apparent from the description, the drawings, and the claims.

BRIEF DESCRIPTION OF THE DRAWINGS

[0013]FIG. 1 illustrates the validation of a computer application having class and interface definitions.

[0014]FIG. 2 is a conceptual block diagram illustrating the validation of a program at the language-independent level and the language-dependent level.

[0015]FIG. 3A is a flow diagram illustrating the validation of a computer program implemented using a compiler-language section.

[0016]FIG. 3B is a flow diagram illustrating the validation of a computer program implemented using a compiler-language section and a script code section.

[0017]FIG. 4 illustrates the validation of a computer program having a compiler-language section and a script code section.

[0018]FIG. 5 illustrates the use of definition and implementation modules to validate a program and generate Hypertext Markup Language (HTML) code.

Like reference numbers and designations in the various drawings indicate like elements. DETAILED DESCRIPTION

[0019] As shown in FIG. 1, in one implementation of the invention, tree structures are used to represent a computer program. These representations are used to generate and validate one or more executable programs, as will be described. The representations can include a tree structure defining the implementation modules, in this particular case, classes to be implemented 100, and a tree structure defining the definition modules, in this particular case, the associated interfaces 105. It is advantageous to define the implementation modules and the definition modules using a language-independent representation. A anguage-independent representation is not restricted to any particular programming language used to implement an executable program. In one exemplary implementation, the implementation modules and the definition modules can be specified in a language that can be used as a meta-language, e.g., Extensible Markup Language (XML). Extended Backus-Naur Form (EBNF), Abstract Syntax Notation One (ASN.1), or LISP.

[0020] The XML descriptions of the interfaces and classes can be used to generate executable programs, for example, by using an Extensible Stylesheet Language (XSL) style sheet 115 in conjunction with an XSL processor 110 to generate program implementation code 120. The executable programs are language-dependent representations specific to a particular programming language used to implement the programs. XSL includes two parts: a language for transforming XML documents, and an XML vocabulary for specifying formatting semantics. An XSL style sheet specifies the presentation of a class of XML documents by describing how an instance of the class is transformed into an XML document that uses the formatting vocabulary. Other technologies, e.g., the Apache Velocity template engine, can be used in place of XSL.

[0021] The program described by the interfaces and classes can be validated at two levels. On the language-independent or XML level, a syntax check is performed for the interface description and the implementation class description. On the language-dependent level, to the extent that the generated implementation code can be compiled, the interface and class definitions can be validated by compiling the code. In this case, the compiler 125 verifies the class and interface definitions by performing usage and implementation checks. Usage checks verify that a customer class only uses interfaces that have been promised by a provider class. Implementation checks verify that the implementation of a provider class provides all the promised interfaces.

[0022]FIG. 2 is a conceptual block diagram illustrating the validation of a program at the language-independent level and the language-dependent level. As described above, a definition module 200 and an implementation module 205 representing the program are received. In one implementation, the computer program can be represented using more than one definition module 200 and/or more than one implementation module 205. The implementation module 205 defines the classes to be implemented by the program and the definition module 200 defines the associated interfaces. The validation at the language-independent level is performed as a syntax check for the definition module 200 and the implementation module 205. The implementation module 205 is used to generate the classes 215 and the definition module 200 is used to generate the associated interfaces 210. Language-dependent validation of the classes 215 and interfaces 210 generated from the language-independent descriptions can be performed by compiling the classes 215 and the interfaces 210 using a compiler 125. The compiler 125 verifies the class and interface definition by performing usage and implementation checks on the language-dependent representation of the classes 215 and the interfaces 210.

[0023]FIG. 3A is a flow diagram illustrating the validation of a computer program implemented using a compiler-language section. A language-independent description of a computer program is received (step 300). As described above, the language-independent description can include implementation modules 205 and definition modules 200 describing the computer program. The language-independent description is validated (step 310) and a syntax check is performed for the implementation modules 205 and the definition modules 200 (step 312). The language-independent description is used to generate a language-dependent program (step 320), e.g., by generating a program implementation using a particular programming language. The language-dependent program is validated (step 330) and usage and semantics checks are performed by compiling the generated interfaces and classes (step 332).

[0024]FIG. 3B is a flow diagram illustrating the validation of a computer program implemented using a compiler-language section and a script language section. As discussed above, a language-independent representation of a computer program is received (step 300), and the language-independent representation is validated (step 310) by performing a syntax check for the implementation modules 205 and definition modules 200 (step 312). A language-dependent representation of the program is generated (step 320), and the generated language-dependent representation is validated (step 330). The generated computer program includes a compiler-language section and a script code section. As described above, the validation of the generated compiler-language section includes usage and semantics checks performed by compiling the generated interfaces 210 and classes 215 (step 332). Usage check of the script code section is performed by extracting the language elements from the script code section (step 331), and comparing the extracted language elements with the definition module (step 333). In order to perform semantics check of the generated script code section, language-dependent code is generated in a language that supports classes and interfaces (step 335). The language-dependent representation for the script code section generated in step 335 implements classes and associated interfaces. Semantics check of the script code section is performed by compiling the generated interfaces 210 and the classes 215 (step 337).

[0025]FIG. 4 illustrates the validation of a computer program having a compiler-language section and a script code section. The XML implementation modules 100 and definition modules 105 represent a computer program. A syntax checker 107 can be used to perform a syntax check at the XML level for the implementation modules 100 and the definition modules 105. Program implementation code for the script code section of the computer program 120 is generated from the implementation modules 100 and the definition modules 105 using an XSL processor 110 in conjunction with XSL style sheets 115. The program implementation code 120 includes a script code implementation of the computer program 121 in a scripting language, e.g., JavaScript or Perl. The program implementation code 120 also includes an implementation of the script code section in an intermediate compiler-language 122 that supports classes and interfaces. A compiler 125 is used to perform implementation checks on the compiler-language implementation of the script code section 122. If the script language generator works properly, the implementation checks performed by the compiler 125 can be used to conclude that the generated script language implementation 121 works accordingly. Usage checks are performed on the script language implementation 121 using a script language parser 127. The script language parser 127 performs usage checks by extracting language elements from the generated script language implementation 121 and comparing the language elements with the definition modules 105.

[0026] Program implementation code for the compiler-language portion of the computer program 130 is generated from the implementation modules 100 and the definition modules 105 using the XSL processor 110 in conjunction with XSL style sheets 116. The compiler 125 verifies the class and interface definitions by performing usage and implementation checks.

[0027]FIG. 5 illustrates use of definition and implementation modules to validate a program and generate HTML code. In FIG. 5, a computer program is represented using a script code section 510 and two XML tree structures 500, 505. The first XML tree structure 500 describes the implementation modules in the form of classes for an HTML document. The second XML tree structure 505 describes definition modules in the form of associated interfaces. The script code section provides the functionality for the HTML document, e.g., support for the scrolling of text. The script code section can be implemented in any scripting language, e.g., JavaScript or Perl. The syntax checker 507 is used to perform a syntax check at the XML level for the implementation modules 500 and the definition modules 505. The HTML document 520 is generated from the implementation modules 500 and the definition modules 505 using the XSL processor 510 in conjunction with XSL style sheets 515. The script language parser 527 performs usage checks by extracting language elements from the script code section 510 and comparing the language elements with the definition modules 505.

[0028] The invention can be implemented in digital electronic circuitry, or in computer hardware, firmware, software, or in combinations of them. The invention can be implemented as a computer program product, i.e., a computer program tangibly embodied in an information carrier, e.g., in a machine-readable storage device or in a propagated signal, for execution by, or to control the operation of, data processing apparatus, e.g., a programmable processor, a computer, or multiple computers. A computer program can be written in any form of programming language, including compiled or interpreted languages, and it can be deployed in any form, including as a stand-alone program or as a module, component, subroutine, or other unit suitable for use in a computing environment. A computer program can be deployed to be executed on one computer or on multiple computers at one site or distributed across multiple sites and interconnected by a communication network.

[0029] Method steps of the invention can be performed by one or more programmable processors executing a computer program to perform functions of the invention by operating on input data and generating output. Method steps can also be performed by, and apparatus of the invention can be implemented as, special purpose logic circuitry, e.g., an FPGA (field programmable gate array) or an ASIC (application-specific integrated circuit).

[0030] Processors suitable for the execution of a computer program include, by way of example, both general and special purpose microprocessors, and any one or more processors of any kind of digital computer. Generally, a processor will receive instructions and data from a read-only memory or a random access memory or both. The essential elements of a computer are a processor for executing instructions and one or more memory devices for storing instructions and data. Generally, a computer will also include, or be operatively coupled to receive data from or transfer data to, or both, one or more mass storage devices for storing data, e.g., magnetic, magneto-optical disks, or optical disks. Information carriers suitable for embodying computer program instructions and data include all forms of non-volatile memory, including by way of example semiconductor memory devices, e.g., EPROM, EEPROM, and flash memory devices; magnetic disks, e.g., internal hard disks or removable disks; magneto-optical disks; and CD-ROM and DVD-ROM disks. The processor and the memory can be supplemented by, or incorporated in special purpose logic circuitry.

[0031] The invention has been described in terms of particular embodiments. Other embodiments are within the scope of the following claims. For example, the steps of the invention can be performed in a different order and still achieve desirable results. 

What is claimed is:
 1. A method for validating programs, the method comprising: receiving a language-independent description of a computer program, the language-independent description comprising a definition module and an implementation module; validating the language-independent description; generating a language-dependent program from the language-independent description, the language-dependent program comprising an interface and a class; and validating the language-dependent program.
 2. The method of claim 1 wherein validating the language-independent description comprises validating the syntax of the definition module and the implementation module.
 3. The method of claim 1 wherein validating the language-dependent program comprises compiling the interface and the class.
 4. The method of claim 1 wherein the definition module and the implementation module are represented in a meta-language or using a tree structure.
 5. A method for validating programs, the method comprising: receiving a language-independent description of a computer program, the language-independent description comprising a definition module and an implementation module; validating the language-independent description; generating a language-dependent program from the language-independent description, the language-dependent program comprising a script code section; and validating the language-dependent program.
 6. The method of claim 5 wherein validating the language-dependent program comprises: extracting language elements from the script code section; and comparing the extracted language elements with the definition module.
 7. The method of claim 6 wherein extracting language elements comprises generating a symbol table from the script code section.
 8. The method of claim 5 wherein generating the language-dependent program comprises: generating language-dependent code comprising an interface and a class.
 9. The method of claim 5, wherein validating the language-dependent program comprises: extracting language elements from the script code section; comparing the extracted language elements with the definition module; generating language-dependent code comprising an interface and a class; and compiling the interface and the class.
 10. A method for validating programs, the method comprising: receiving a language-independent description of a computer program, the language-independent description comprising a definition module and an implementation module; validating the language-independent description; generating a first language-dependent program from the language-independent description, the first language-dependent program comprising a first script code section; generating a second language-dependent program from the language-dependent description, the second language-dependent program comprising a second script code section of a distinct, second kind; extracting a first set of language elements from the first script code section; extracting a second set of language elements from the second script code section; and comparing the first set of language elements and the second set of language elements with the definition module.
 11. A computer program product, tangibly embodied in an information carrier, the computer program product comprising instructions operable to cause data processing equipment to: receive a language-independent description of a computer program, the language-independent description comprising a definition module and an implementation module; validate the language-independent description; generate a language-dependent program from the language-independent description, the language-dependent program comprising an interface and a class; and validate the language-dependent program.
 12. The computer program product of claim 11, wherein the instructions to validate the language-independent description cause the data processing equipment to validate the syntax of the definition module and the implementation module.
 13. The computer program product of claim 11, wherein the instructions to validate the language-dependent program cause the data processing equipment to compile the interface and the class.
 14. The computer program product of claim 11 wherein the definition module and the implementation module are represented in a meta-language.
 15. A computer program product, tangibly embodied in an information carrier, the computer program product comprising instructions operable to cause data processing equipment to: receive a language-independent description of a computer program, the language-independent description comprising a definition module and an implementation module; validate the language-independent description; generate a language-dependent program from the language-independent description, the language-dependent program comprising a script code section; and validate the language-dependent program.
 16. The computer program product of claim 15, wherein the instructions to validate the language-dependent program cause the data processing equipment to: extract language elements from the script code section; and compare the extracted language elements with the definition module.
 17. The computer program product of claim 16 wherein the instructions to extract the language elements cause the data processing equipment to generate a symbol table from the script code section.
 18. The computer program product of claim 15, wherein the instructions to generate the language-dependent program cause the data processing equipment to: generate language-dependent code comprising an interface and a class.
 19. The computer program product of claim 15 wherein the instructions to validate the language-dependent program cause the data processing equipment to: extract language elements from the script code section; compare the extracted language elements with the definition module; generate language-dependent code comprising an interface and a class; and compile the interface and the class.
 20. A computer program product, tangibly embodied in an information carrier, the computer program product comprising instructions operable to cause data processing equipment to: receive a language-independent description of a computer program, the language-independent description comprising a definition module and an implementation module; validate the language-independent description; generate a first language-dependent program from the language-independent description, the first language-dependent program comprising a first script code section; generate a second language-dependent program from the language-dependent description, the second language-dependent program comprising a second script code section of a distinct, second kind; extract a first set of language elements from the first script code section; extract a second set of language elements from the second script code section; and compare the first set of language elements and the second set of language elements with the definition module.
 21. An apparatus, comprising: means for receiving a language-independent description of a computer program, the language-independent description comprising a definition module and an implementation module; means for validating the language-independent description; means for generating a language-dependent program from the language-independent description, the language-dependent program comprising an interface and a class; and means for validating the language-dependent program. 